\(\int x^2 \tan ^3(a+b x) \, dx\) [12]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 12, antiderivative size = 128 \[ \int x^2 \tan ^3(a+b x) \, dx=\frac {x^2}{2 b}-\frac {i x^3}{3}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}-\frac {\log (\cos (a+b x))}{b^3}-\frac {i x \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^2}+\frac {\operatorname {PolyLog}\left (3,-e^{2 i (a+b x)}\right )}{2 b^3}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b} \]

[Out]

1/2*x^2/b-1/3*I*x^3+x^2*ln(1+exp(2*I*(b*x+a)))/b-ln(cos(b*x+a))/b^3-I*x*polylog(2,-exp(2*I*(b*x+a)))/b^2+1/2*p
olylog(3,-exp(2*I*(b*x+a)))/b^3-x*tan(b*x+a)/b^2+1/2*x^2*tan(b*x+a)^2/b

Rubi [A] (verified)

Time = 0.22 (sec) , antiderivative size = 128, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.667, Rules used = {3801, 3556, 30, 3800, 2221, 2611, 2320, 6724} \[ \int x^2 \tan ^3(a+b x) \, dx=\frac {\operatorname {PolyLog}\left (3,-e^{2 i (a+b x)}\right )}{2 b^3}-\frac {\log (\cos (a+b x))}{b^3}-\frac {i x \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^2}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}+\frac {x^2 \tan ^2(a+b x)}{2 b}+\frac {x^2}{2 b}-\frac {i x^3}{3} \]

[In]

Int[x^2*Tan[a + b*x]^3,x]

[Out]

x^2/(2*b) - (I/3)*x^3 + (x^2*Log[1 + E^((2*I)*(a + b*x))])/b - Log[Cos[a + b*x]]/b^3 - (I*x*PolyLog[2, -E^((2*
I)*(a + b*x))])/b^2 + PolyLog[3, -E^((2*I)*(a + b*x))]/(2*b^3) - (x*Tan[a + b*x])/b^2 + (x^2*Tan[a + b*x]^2)/(
2*b)

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2221

Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/((a_) + (b_.)*((F_)^((g_.)*((e_.) +
 (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x]
 - Dist[d*(m/(b*f*g*n*Log[F])), Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x], x] /; FreeQ[{F,
a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]

Rule 2320

Int[u_, x_Symbol] :> With[{v = FunctionOfExponential[u, x]}, Dist[v/D[v, x], Subst[Int[FunctionOfExponentialFu
nction[u, x]/x, x], x, v], x]] /; FunctionOfExponentialQ[u, x] &&  !MatchQ[u, (w_)*((a_.)*(v_)^(n_))^(m_) /; F
reeQ[{a, m, n}, x] && IntegerQ[m*n]] &&  !MatchQ[u, E^((c_.)*((a_.) + (b_.)*x))*(F_)[v_] /; FreeQ[{a, b, c}, x
] && InverseFunctionQ[F[x]]]

Rule 2611

Int[Log[1 + (e_.)*((F_)^((c_.)*((a_.) + (b_.)*(x_))))^(n_.)]*((f_.) + (g_.)*(x_))^(m_.), x_Symbol] :> Simp[(-(
f + g*x)^m)*(PolyLog[2, (-e)*(F^(c*(a + b*x)))^n]/(b*c*n*Log[F])), x] + Dist[g*(m/(b*c*n*Log[F])), Int[(f + g*
x)^(m - 1)*PolyLog[2, (-e)*(F^(c*(a + b*x)))^n], x], x] /; FreeQ[{F, a, b, c, e, f, g, n}, x] && GtQ[m, 0]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3800

Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[I*((c + d*x)^(m + 1)/(d*(m + 1))), x
] - Dist[2*I, Int[(c + d*x)^m*(E^(2*I*(e + f*x))/(1 + E^(2*I*(e + f*x)))), x], x] /; FreeQ[{c, d, e, f}, x] &&
 IGtQ[m, 0]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rule 6724

Int[PolyLog[n_, (c_.)*((a_.) + (b_.)*(x_))^(p_.)]/((d_.) + (e_.)*(x_)), x_Symbol] :> Simp[PolyLog[n + 1, c*(a
+ b*x)^p]/(e*p), x] /; FreeQ[{a, b, c, d, e, n, p}, x] && EqQ[b*d, a*e]

Rubi steps \begin{align*} \text {integral}& = \frac {x^2 \tan ^2(a+b x)}{2 b}-\frac {\int x \tan ^2(a+b x) \, dx}{b}-\int x^2 \tan (a+b x) \, dx \\ & = -\frac {i x^3}{3}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b}+2 i \int \frac {e^{2 i (a+b x)} x^2}{1+e^{2 i (a+b x)}} \, dx+\frac {\int \tan (a+b x) \, dx}{b^2}+\frac {\int x \, dx}{b} \\ & = \frac {x^2}{2 b}-\frac {i x^3}{3}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}-\frac {\log (\cos (a+b x))}{b^3}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b}-\frac {2 \int x \log \left (1+e^{2 i (a+b x)}\right ) \, dx}{b} \\ & = \frac {x^2}{2 b}-\frac {i x^3}{3}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}-\frac {\log (\cos (a+b x))}{b^3}-\frac {i x \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^2}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b}+\frac {i \int \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right ) \, dx}{b^2} \\ & = \frac {x^2}{2 b}-\frac {i x^3}{3}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}-\frac {\log (\cos (a+b x))}{b^3}-\frac {i x \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^2}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b}+\frac {\text {Subst}\left (\int \frac {\operatorname {PolyLog}(2,-x)}{x} \, dx,x,e^{2 i (a+b x)}\right )}{2 b^3} \\ & = \frac {x^2}{2 b}-\frac {i x^3}{3}+\frac {x^2 \log \left (1+e^{2 i (a+b x)}\right )}{b}-\frac {\log (\cos (a+b x))}{b^3}-\frac {i x \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^2}+\frac {\operatorname {PolyLog}\left (3,-e^{2 i (a+b x)}\right )}{2 b^3}-\frac {x \tan (a+b x)}{b^2}+\frac {x^2 \tan ^2(a+b x)}{2 b} \\ \end{align*}

Mathematica [A] (verified)

Time = 2.28 (sec) , antiderivative size = 172, normalized size of antiderivative = 1.34 \[ \int x^2 \tan ^3(a+b x) \, dx=\frac {e^{-i a} \left (2 b^2 x^2 \left (2 i b x+3 \left (1+e^{2 i a}\right ) \log \left (1+e^{-2 i (a+b x)}\right )\right )+6 i b \left (1+e^{2 i a}\right ) x \operatorname {PolyLog}\left (2,-e^{-2 i (a+b x)}\right )+3 \left (1+e^{2 i a}\right ) \operatorname {PolyLog}\left (3,-e^{-2 i (a+b x)}\right )\right ) \sec (a)+6 b^2 x^2 \sec ^2(a+b x)-12 b x \sec (a) \sec (a+b x) \sin (b x)-4 b^3 x^3 \tan (a)-12 (\log (\cos (a+b x))+b x \tan (a))}{12 b^3} \]

[In]

Integrate[x^2*Tan[a + b*x]^3,x]

[Out]

(((2*b^2*x^2*((2*I)*b*x + 3*(1 + E^((2*I)*a))*Log[1 + E^((-2*I)*(a + b*x))]) + (6*I)*b*(1 + E^((2*I)*a))*x*Pol
yLog[2, -E^((-2*I)*(a + b*x))] + 3*(1 + E^((2*I)*a))*PolyLog[3, -E^((-2*I)*(a + b*x))])*Sec[a])/E^(I*a) + 6*b^
2*x^2*Sec[a + b*x]^2 - 12*b*x*Sec[a]*Sec[a + b*x]*Sin[b*x] - 4*b^3*x^3*Tan[a] - 12*(Log[Cos[a + b*x]] + b*x*Ta
n[a]))/(12*b^3)

Maple [A] (verified)

Time = 0.30 (sec) , antiderivative size = 180, normalized size of antiderivative = 1.41

method result size
risch \(-\frac {i x^{3}}{3}+\frac {2 x \left (b x \,{\mathrm e}^{2 i \left (b x +a \right )}-i {\mathrm e}^{2 i \left (b x +a \right )}-i\right )}{b^{2} \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )^{2}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (b x +a \right )}\right )}{b^{3}}+\frac {4 i a^{3}}{3 b^{3}}+\frac {2 i a^{2} x}{b^{2}}+\frac {x^{2} \ln \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}{b}-\frac {i x \,\operatorname {Li}_{2}\left (-{\mathrm e}^{2 i \left (b x +a \right )}\right )}{b^{2}}+\frac {\operatorname {Li}_{3}\left (-{\mathrm e}^{2 i \left (b x +a \right )}\right )}{2 b^{3}}-\frac {\ln \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}{b^{3}}+\frac {2 \ln \left ({\mathrm e}^{i \left (b x +a \right )}\right )}{b^{3}}\) \(180\)

[In]

int(x^2*tan(b*x+a)^3,x,method=_RETURNVERBOSE)

[Out]

-1/3*I*x^3+2*x*(b*x*exp(2*I*(b*x+a))-I*exp(2*I*(b*x+a))-I)/b^2/(exp(2*I*(b*x+a))+1)^2-2/b^3*a^2*ln(exp(I*(b*x+
a)))+4/3*I/b^3*a^3+2*I/b^2*a^2*x+x^2*ln(exp(2*I*(b*x+a))+1)/b-I*x*polylog(2,-exp(2*I*(b*x+a)))/b^2+1/2*polylog
(3,-exp(2*I*(b*x+a)))/b^3-1/b^3*ln(exp(2*I*(b*x+a))+1)+2/b^3*ln(exp(I*(b*x+a)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 240 vs. \(2 (109) = 218\).

Time = 0.26 (sec) , antiderivative size = 240, normalized size of antiderivative = 1.88 \[ \int x^2 \tan ^3(a+b x) \, dx=\frac {2 \, b^{2} x^{2} \tan \left (b x + a\right )^{2} + 2 \, b^{2} x^{2} + 2 i \, b x {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) - 2 i \, b x {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) - 4 \, b x \tan \left (b x + a\right ) + 2 \, {\left (b^{2} x^{2} - 1\right )} \log \left (-\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) + 2 \, {\left (b^{2} x^{2} - 1\right )} \log \left (-\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) + {\rm polylog}\left (3, \frac {\tan \left (b x + a\right )^{2} + 2 i \, \tan \left (b x + a\right ) - 1}{\tan \left (b x + a\right )^{2} + 1}\right ) + {\rm polylog}\left (3, \frac {\tan \left (b x + a\right )^{2} - 2 i \, \tan \left (b x + a\right ) - 1}{\tan \left (b x + a\right )^{2} + 1}\right )}{4 \, b^{3}} \]

[In]

integrate(x^2*tan(b*x+a)^3,x, algorithm="fricas")

[Out]

1/4*(2*b^2*x^2*tan(b*x + a)^2 + 2*b^2*x^2 + 2*I*b*x*dilog(2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1) - 2
*I*b*x*dilog(2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1) - 4*b*x*tan(b*x + a) + 2*(b^2*x^2 - 1)*log(-2*(
I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) + 2*(b^2*x^2 - 1)*log(-2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1))
 + polylog(3, (tan(b*x + a)^2 + 2*I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) + polylog(3, (tan(b*x + a)^2 - 2*I
*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)))/b^3

Sympy [F]

\[ \int x^2 \tan ^3(a+b x) \, dx=\int x^{2} \tan ^{3}{\left (a + b x \right )}\, dx \]

[In]

integrate(x**2*tan(b*x+a)**3,x)

[Out]

Integral(x**2*tan(a + b*x)**3, x)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 736 vs. \(2 (109) = 218\).

Time = 0.66 (sec) , antiderivative size = 736, normalized size of antiderivative = 5.75 \[ \int x^2 \tan ^3(a+b x) \, dx=\text {Too large to display} \]

[In]

integrate(x^2*tan(b*x+a)^3,x, algorithm="maxima")

[Out]

-1/2*(a^2*(1/(sin(b*x + a)^2 - 1) - log(sin(b*x + a)^2 - 1)) + 2*(2*(b*x + a)^3 - 6*(b*x + a)^2*a - 6*((b*x +
a)^2 - 2*(b*x + a)*a + ((b*x + a)^2 - 2*(b*x + a)*a - 1)*cos(4*b*x + 4*a) + 2*((b*x + a)^2 - 2*(b*x + a)*a - 1
)*cos(2*b*x + 2*a) - (-I*(b*x + a)^2 + 2*I*(b*x + a)*a + I)*sin(4*b*x + 4*a) - 2*(-I*(b*x + a)^2 + 2*I*(b*x +
a)*a + I)*sin(2*b*x + 2*a) - 1)*arctan2(sin(2*b*x + 2*a), cos(2*b*x + 2*a) + 1) + 2*((b*x + a)^3 - 3*(b*x + a)
^2*a - 6*b*x - 6*a)*cos(4*b*x + 4*a) + 4*((b*x + a)^3 - 3*(b*x + a)^2*(a - I) + 3*(b*x + a)*(-2*I*a - 1) - 3*a
)*cos(2*b*x + 2*a) + 6*(b*x*cos(4*b*x + 4*a) + 2*b*x*cos(2*b*x + 2*a) + I*b*x*sin(4*b*x + 4*a) + 2*I*b*x*sin(2
*b*x + 2*a) + b*x)*dilog(-e^(2*I*b*x + 2*I*a)) + 3*(I*(b*x + a)^2 - 2*I*(b*x + a)*a + (I*(b*x + a)^2 - 2*I*(b*
x + a)*a - I)*cos(4*b*x + 4*a) + 2*(I*(b*x + a)^2 - 2*I*(b*x + a)*a - I)*cos(2*b*x + 2*a) - ((b*x + a)^2 - 2*(
b*x + a)*a - 1)*sin(4*b*x + 4*a) - 2*((b*x + a)^2 - 2*(b*x + a)*a - 1)*sin(2*b*x + 2*a) - I)*log(cos(2*b*x + 2
*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1) + 3*(I*cos(4*b*x + 4*a) + 2*I*cos(2*b*x + 2*a) - sin(4*b*
x + 4*a) - 2*sin(2*b*x + 2*a) + I)*polylog(3, -e^(2*I*b*x + 2*I*a)) + 2*(I*(b*x + a)^3 - 3*I*(b*x + a)^2*a - 6
*I*b*x - 6*I*a)*sin(4*b*x + 4*a) + 4*(I*(b*x + a)^3 + 3*(b*x + a)^2*(-I*a - 1) + 3*(b*x + a)*(2*a - I) - 3*I*a
)*sin(2*b*x + 2*a) - 12*a)/(-6*I*cos(4*b*x + 4*a) - 12*I*cos(2*b*x + 2*a) + 6*sin(4*b*x + 4*a) + 12*sin(2*b*x
+ 2*a) - 6*I))/b^3

Giac [F]

\[ \int x^2 \tan ^3(a+b x) \, dx=\int { x^{2} \tan \left (b x + a\right )^{3} \,d x } \]

[In]

integrate(x^2*tan(b*x+a)^3,x, algorithm="giac")

[Out]

integrate(x^2*tan(b*x + a)^3, x)

Mupad [F(-1)]

Timed out. \[ \int x^2 \tan ^3(a+b x) \, dx=\int x^2\,{\mathrm {tan}\left (a+b\,x\right )}^3 \,d x \]

[In]

int(x^2*tan(a + b*x)^3,x)

[Out]

int(x^2*tan(a + b*x)^3, x)